<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.util.Calendar"%>
<%@page import="crm.util.ParamUtil"%>
<%@page import="crm.control.EmployeesControl"%>
<%@page import="crm.model.Employees"%>
<%@page import="crm.control.StatisticsControl"%>
<%@page import="crm.model.Statistics" %>
<%@page import="java.util.Collection" %>
<%@page import="java.util.Iterator" %>
<%@page import="crm.model.Recepit"  %>
<%@page import="crm.control.RecepitControl" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html >
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>天成科技CRM管理系统</title>
<!--                       CSS                       -->
<!-- Reset Stylesheet -->
<link rel="stylesheet" href="../../../resources/css/reset.css" type="text/css" media="screen" />
<!-- Main Stylesheet -->
<link rel="stylesheet" href="../../../resources/css/style.css" type="text/css" media="screen" />
<!-- Invalid Stylesheet. This makes stuff look pretty. Remove it if you want the CSS completely valid -->
<link rel="stylesheet" href="../../../resources/css/invalid.css" type="text/css" media="screen" />
<!--                       Javascripts                       -->
<!-- jQuery -->
<script type="text/javascript" src="../../../resources/scripts/jquery-1.3.2.min.js"></script>
<!-- jQuery Configuration -->
<script type="text/javascript" src="../../../resources/scripts/simpla.jquery.configuration.js"></script>
 <script type="text/javascript" src="../../../resources/js/WebCalendar.js"></script>
<!-- Facebox jQuery Plugin -->
<script type="text/javascript" src="../../../resources/scripts/facebox.js"></script>
<!-- jQuery WYSIWYG Plugin -->
<script type="text/javascript" src="../../../resources/scripts/jquery.wysiwyg.js"></script>
<!-- jQuery Datepicker Plugin -->
<script type="text/javascript" src="../../../resources/scripts/jquery.datePicker.js"></script>
<script type="text/javascript" src="../../../resources/scripts/jquery.date.js"></script>
<script type="text/javascript" src="../../../resources/js/reinitIframe.js"></script>
<script type='text/javascript'>
window.onload=function(){
	setInterval(function(){
		new ReinitIframe('iinformation');
	},200);
}


</script>
<style type="text/css">
.hide{
    position: absolute;
    zoom: 0.001;
    -moz-transform: scale(0);
    -webkit-transform: scale(0);
    -o-transform: scale(0);
    transform: scale(0);
}
</style>
</head>
<body>
<%
 Employees cu = (Employees)session.getAttribute("user");
String year = "";
String month  ="";
String employee_name = "";
String recepit_title = "";
//int employee_id;
//int recepit_id;

Calendar cal = Calendar.getInstance();
int startYear = 2011;;
int endYear = cal.get(Calendar.YEAR);  //为当前年份
int type=ParamUtil.getInt(request,"type",0);
if(type==1){
	 year = ParamUtil.getString(request,"year",String.valueOf(endYear));
	 month = ParamUtil.getString(request,"month",null);
	 employee_name = ParamUtil.getString(request,"employee_name",null);
	 recepit_title = ParamUtil.getString(request,"recepit_title",null);
	 
	 session.setAttribute("year",year);
	 session.setAttribute("month",month);
	 session.setAttribute("employee_id",employee_name);
	 session.setAttribute("recepit_id",recepit_title);
}else{
	 year = (String)session.getAttribute("year");
	 month = (String)session.getAttribute("month");
	 employee_name = (String)session.getAttribute("employee_name");
	 recepit_title = (String)session.getAttribute("recepit_title");
}

%>

<div id="body-wrapper">
  <!-- Wrapper for the radial gradient background -->
  <div id="sidebar">
    <div id="sidebar-wrapper">
      <!-- Sidebar with logo and menu -->
      <h1 id="sidebar-title"><a href="#">Simpla Admin</a></h1>
      <!-- Logo (221px wide) -->
      <a href="#"><img id="logo" src="../../../resources/css/slice/notice.png" 

alt="Simpla Admin logo" /></a>
      <!-- Sidebar Profile links -->
      <div id="profile-links"> <a href="#"><%=EmployeesControl.getEmployeesName

(cu.getId())%>,您好！</a> <br />
        <br />
        <a href="#information" rel='modal' >修改个人信息</a> | <a 

href="../../login/logout.jsp" title="Sign Out">注销</a> </div>
      <ul id="main-nav">
        <!-- Accordion Menu -->
       <li> <a href="#" class="nav-top-item">公司页面 </a>
          <ul>
	          <li><a href='../../common/company/material/material_download.jsp'>资料 </a></li>
	          <li><a href='../../common/company/notice/notice.jsp'>公告</a></li>
	          <li><a href='../../common/company/salearea/salearea.jsp'>销售区域</a></li>
	          <li><a href='../../common/company/saletarget/saletarget.jsp'>销售目标</a></li>
          </ul>
         </li>
        <li> <a href="../../common/recepit/show_all_recepits.jsp" class="nav-top-item no-submenu">
          <!-- Add the class "current" to current menu item -->我的跟单</a>
        
        </li>
        <li> <a href="../../common/offer/show_all_offers.jsp" class="nav-top-item no-submenu">报<span class='letter'>价</span></a>      
        </li>
        <li> <a href="../../common/bargain/show_all_bargains.jsp" class="nav-top-item no-submenu">合<span class='letter'>同</span></a>
        </li>
        <li> <a href="../../common/schedule/schedule.jsp" class="nav-top-item no-submenu">日<span class='letter'>程</span></a></li>
        <li> <a href="../../common/customer/customer.jsp" class="nav-top-item no-submenu">我的客户</a>
        <%
            if(cu.getPosition()!=1){
            	%>
            	<li> <a href="#" class="nav-top-item current">统<span class='letter'>计</span></a>
		          <ul>
		            <li><a class='current' href="../../control/statistics/company_statistics.jsp">公司统计</a></li>
		            <li><a href="../../control/statistics/employees_statistics.jsp">员工统计</a></li>
		          </ul>
		        </li>
            	<li><a href="../../common/employees/employees.jsp" class="nav-top-item no-submenu">员工管理</a></li>
            	<%
            }
        %>
        </li>
      </ul>
    </div>
  </div>
  <div id="main-content">
  <img src='../../../resources/css/slice/t.png'/>
  <form action="company_statistics.jsp?type=1" method="post">
	 <div class="content-box-header">
	 <h3 style="cursor: s-resize;">搜索条件</h3>
	 </div>
	 <table border='1' class='search'>
<tr>
<td><select name="year" style='width: 100px;text-align:center;'>
<%
 for(int y =startYear;y<=endYear;y++ ){
%>
<option value="<%=y %>"  <%//if(year!=null&&year.equals(String.valueOf(y))) out.print("selected='selected'"); %>><%=y %></option>
<%} %>
</td>
<td width='100'>年</td>
<td><select  autocomplete="off" name="month" style='width: 100px;text-align:center;'>
<option value="0"  >选择月份</option>
<%
for(int m=1;m<=12;m++){
%>
<option value="<%=m %>" <%//if(month!=null&&month.equals(String.valueOf(m))) out.print("selected='selected'"); %> ><%=m %></option>
<%} %>
</td>
<td width='100'>月</td>
<td>员工姓名：</td><td><input type="text" name="employee_name" value="<%if(employee_name!=null&&!employee_name.equals("")) out.print(employee_name); %>"></td>
<td>跟单项目名称</td><td><input type="text" name="recepit_title" value="<%if(recepit_title!=null&&!recepit_title.equals("")) out.print(recepit_title);%>"/></td>
<td><input type="submit" class='button' value="搜索"></td>
</tr>
</table>
</form>
<p class='title'>您当前选择的是：
<%
if(year!=null&&!year.equals("")){
out.print(year+"年");
}
if(month!=null&&!month.equals("")){
	if(month.equals("0")){
		out.print("所有月份");
	}else{
out.print(month+"月");
	}
}
%>
</p>
<p>
<span style='color:#5DA500'>销售额：</span><%out.print(StatisticsControl.getXiaoShouE("",year,month)); %>
<span style='color:#5DA500'>回款额：</span><%out.println(StatisticsControl.getStaistics("","",year,month)); %>
</p>
<form>
 <div class="content-box-header">
<h3 style="cursor: s-resize;">搜索结果</h3>
</div>
<table>
<thead>
<tr>
<th>回款金额</th>
<th>回款人</th>
<th>跟单项目名称</th>
<th>日期</th>
</tr>
</thead>
<tbody>
 <%
				        int pages = ParamUtil.getInt(request, "pages", 0);
						int rowsPerpage = ParamUtil.getInt(request, "pageSize", 10);
						int i=0;
						Collection statistics=StatisticsControl.getAllStaistics(employee_name,recepit_title,year,month,rowsPerpage,pages);
						Iterator iterator=statistics.iterator();
						while(iterator.hasNext()){
						   i++;
						   Statistics statistics2=(Statistics)iterator.next();
						
				       %>
<tr>
<td><%=statistics2.getAdd_money() %></td>
<td><%=EmployeesControl.getEmployeesName(statistics2.getEmployee_id()) %></td>
<td><%=RecepitControl.getRecepitById(statistics2.getRecepit_id()).getTitle() %></td>
<td><%=statistics2.getDate() %></td>
<!--  td><%=StatisticsControl.getStaistics("","",year,month) %></td>-->
<!--  td><%=StatisticsControl.getXiaoShouE("",year,month) %></td>-->
</tr>
</tbody>
<%} %>
</table>
<%     out.println(StatisticsControl.pageInstance.getToolsMenu(pages));
              
 %>
</form>
<div class='hide' >
	<div id='information'>
		<iframe id='iinformation' style='width:368px; overflow:hidden;' scrolling='no' frameborder='0' src='../../common/employees/employees_update.jsp'></iframe>
	</div>
</div>
</div>
</div>
</html>